package com.yilin.tms.core.entity.zhiyun;

import com.yilin.commons.util.DateTimeUtil;
import com.yilin.commons.util.StringUtil;

import java.util.Date;

public class ZyResData<Result> {

    private Result result;
    private int status;

    public boolean isSuccess(){
        return status==1001;
    }
    public String getStatusName(){
        String name="客户端请求错误，请检查代码";
        switch (status){
            case 1001:name="接口执行成功";break;
            case 1002:name="参数不正确（参数为空、查询时间范围不正确、参数数量不正确）";break;
            case 1003:name="服务调用数量已达上限";break;
            case 1004:name="服务调用次数已达上限";break;
            case 1005:name="该账号未授权指定所属行政区划范围";break;
            case 1006:name="无结果";break;
            case 1010:name="用户名或密码不正确";break;
            case 1011:name="IP 不在白名单列表";break;
            case 1012:name="账号已禁用";break;
            case 1013:name="账号已过有效期";break;
            case 1014:name="无接口权限";break;
            case 1015:name="用户认证系统已升级，请使用令牌访问";break;
            case 1016:name="令牌失效";break;
            case 1017:name="账号欠费";break;
            case 1018:name="授权的服务已禁用";break;
            case 1019:name="授权的服务已过期";break;
            case 1020:name="该车调用次数已达上限";break;
            case 1021:name="client_id 不正确";break;
            case 1031:name="签名验证失败";break;
            case 1050:name="没有购买此类套餐";break;
            case 1051:name="套餐服务能力已用尽";break;
            case 1052:name="用户不存在";break;
            case 1053:name="服务无对应有效套餐";break;
            case 1060:name="新能源车辆已订阅，暂时无结果";break;
            case 9001:name="系统异常";break;
        }
        return name;
    }

    public String getKeyName(String key){
        switch (key){
            case "result":return "返回结果:";

            case "vclLng":return "外廓尺寸-长(mm):";
            case "boxWdt":return "内廓尺寸-宽(mm):";
            case "vehicleAxis":return "车轴数:";
            case "prdCdNm":return "车辆型号:";
            case "boxHgt":return "内廓尺寸-高(mm):";
            case "drvLicDt":return "行驶证发证日期:";
            case "city":return "市编码:";
            case "country":return "县:";
            case "vclWnrPhn":return "联系人手机:";
            case "vclWnrNm":return "联系人:";
            case "vclHgt":return "外廓尺寸-高(mm) :";
            case "vclTon":return "总质量/准牵引总质量:";
            case "vclTpNm":return "车辆类型:";
            case "cmpNm":return "车主/业户:";
            case "vin":return "车辆识别代码/车架号:";
            case "boxLng":return "内廓尺寸-长(mm) :";
            case "province":return "省编码:";
            case "ldTn":return "核定载重量:";
            case "vclWdt":return "外廓尺寸-宽(mm):";
            case "ctyCode":return "县编码:";
            case "vbrndCdNm":return "车辆品牌:";
            case "drvLicVdy":return "行驶证有效期 UTC:";

            case "roadTransport":return "道路运输证号码:";
            case "vdtTm":return "有效期:";
            case "vehiclePlateColor":return "颜色:";
            case "startDate":return "道路运输证开始日期:";
            case "roadLicense":return "证件号:";
            case "issueDartp":return "道路运输证签发机构:";
            case "licenseFirstDate":return "道路运输证发证日期:";
            case "endDate":return "道路运输证结束日期:";
            case "vehiclePlateNo":return "车牌号:";

            case "enterpriseName":return "企业名称:";
            case "customerAddressDetail":return "企业注册地址:";
            case "authDate":return "授权日期:";
            case "authDepartment":return "授权部门:";
            case "vehicleBusinessScope":return "经营范围:";
            case "authStartTime":return "授权起始日期:";
            case "authEndTime":return "授权结束日期:";
            case "customerAddressCityCode":return "企业区县编码:";

            case "isExist":return "是否存在:";

            case "userName":return "用户姓名:";
            case "sex":return "性别:";
            case "birthday":return "生日（年龄）:";
            case "licenceo":return "从业资格证号:";
            case "firstFecth":return "证件初次领取日期:";
            case "startTime":return "期限开始日期:";
            case "endTime":return "期限结束日期:";
            case "licenceCodeType":return "从业资格类别代码:";
            case "userPhone":return "用户手机号:";
            case "idCardNmber":return "身份证号:";
        }
        return key;
    }

    public String getValueName(ZyReqData.ReqItem reqItem,String key,String value){
        if (reqItem == ZyReqData.ReqItem.checkVehicleExist){
            return "验证成功，最新定位时间"+ DateTimeUtil.dateToString(new Date(Long.parseLong(value)),"yyyy-MM-dd");
        }
        switch (value){
            case "yes":return "<span style=\"color:green\">验证成功</span>";
            case "no" :return "<span style=\"color:red\">验证失败</span>";
            case "name":return "车主姓名不正确:";
            case "phone":return "手机号码不正确:";
        }
        switch (key){
            case "drvLicVdy":
            case "vdtTm":
            case "startDate":
            case "licenseFirstDate":
            case "endDate":
            case "authDate":
            case "authStartTime":
            case "authEndTime":
            case "firstFecth":
            case "startTime":
            case "endTime":
                if (!value.contains("-") && StringUtil.isNotEmpty(value)){
                    return DateTimeUtil.dateToString(new Date(Long.parseLong(value)),"yyyy-MM-dd");
                }
        }
        return value;
    }

    public Result getResult() {
        return result;
    }

    public void setResult(Result result) {
        this.result = result;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }
}
